<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';
require_once './include/advisory_db.php';

/*
$nav = new buildNav;
$nav->limit=10;

$result = $DB->query("SELECT COUNT(*) AS count FROM  pa_applicant as b RIGHT JOIN pa_job as a ON a.jo_id = b.app_jobid $where $order");
$count = 0;
while($list = $DB->fetch_array($result)){
  $count++;
}

//$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_job as a ,pa_applicant as b $where $order");
$nav->total_result =  $count;
//echo "SELECT COUNT(*) AS count,a.*,b.* FROM pa_job as a ,pa_applicant as b $where $order";
$nav->execute("SELECT COUNT(*) AS count,a.*,b.*  FROM  pa_applicant as b RIGHT JOIN pa_job as a ON a.jo_id = b.app_jobid $where $order");

$page = $nav->pagenav();

*/
$nav = new buildNav;
$nav->limit=25;

$result = $DB->query("SELECT COUNT(*) AS count FROM  pa_applicant as b RIGHT JOIN pa_job as a ON a.jo_id = b.app_jobid WHERE `jo_utype`='employer' AND `jo_uid`='".$_SESSION[uid]."' GROUP BY jo_id ORDER BY jo_id DESC");
$nav->total_result =  $count;
$count = 0;
while($list = $DB->fetch_array($result)){
  $count++;
}
$nav->total_result =  $count;
$nav->execute("SELECT 
					COUNT(*) AS count,a.*,b.*  
				FROM  
					pa_applicant as b 
				RIGHT JOIN 
					pa_job as a 
				ON 
					a.jo_id = b.app_jobid 
				WHERE 
					`jo_utype`='employer' 
				AND 
					`jo_uid`='".$_SESSION[uid]."'  
				GROUP BY jo_id ORDER BY jo_id DESC");

$i=0;
while($list3 = $DB->fetch_array($nav->sql_result)){
   $data_job[$i]              = $list3;
   $data_job[$i][jo_function] = $jobfunction[$list3[jo_function]];
   $data_job[$i][jo_status]   = $jobfillstatus[$list3[jo_status]];
   //BEGIN: modify for  by aaron on 2011-09-30
   //$data_job[$i][jo_applicants] = getNumberOfApplicants($data_job[$i][jo_id]);
   $sql = "SELECT 
				COUNT(*) AS count 
			FROM 
				pa_contact as a ,pa_job as b  
			WHERE  
				b.jo_id = a.re_aliasid 
			AND 
				a.re_aliasid = '".$data_job[$i][jo_id]."' AND b.jo_uid = '".$_SESSION[uid]."'";
	$mesageCount = $DB->fetch_one_array($sql);	
	$data_job[$i][jo_applicants] = $mesageCount[count];
	//END: modify for  by aaron on 2011-09-30
   $data_job[$i][jo_regtime]  = date("F j, Y",$list3[jo_regtime]);
   $i++;
}
//print_r($data_job);
$smarty->assign("joblist",$data_job);

$sql      = "SELECT * FROM pa_employer ORDER BY ep_id DESC LIMIT 0,9";
$result = $DB->query($sql);
$i=0;
while($list = $DB->fetch_array($result)){
   $data_list[$i][a0] = $list[ep_uname];
   $data_list[$i][a1] = $jobcategory[$list[ep_industry]];
   $data_list[$i][a2] = $list[ep_copsize];
   $data_list[$i][a3] = $state[$list[ep_state]].",".$country[$list[ep_country]];
   $data_list[$i][a5] = $list[ep_id];
  $i++;
}
$smarty->assign("emplist",$data_list);

$smarty->assign('rss1',"<img src='images/ajax.gif' />");
$smarty->assign('rss2',"<img src='images/ajax.gif' />");


$smarty->display('header.tpl');
$smarty->display('allleft.tpl');
$smarty->display('emplist.tpl');

$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
